class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-10-23",
      revision: "4f2cf56b3145f4ec8e579b56db663261c3bafd78"
  version "2021-10-23"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "1fda585cf2b1bfc2dfe557d31694bb603f8aa523bffc199e8c1e561e9e45232f"
    sha256 cellar: :any_skip_relocation, big_sur:       "b458a94b5a854e0a71d2d15b3877a828704f19a2c3da03ae986103e0a9682606"
    sha256 cellar: :any_skip_relocation, catalina:      "8569c3c7b1502cd485d1f5019e0d8deda5cda462f22a8e1cef93efdaed8edc37"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "a1a8b1828644001ba945fb0814531b7a166310a2f7c52a1d129aea4f5f6767e7"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
